/*Author:zhaoyihang
 * Description:初始化线程池
 *
 * typedef struct threadPool_s {
    pthread_t *tidArr;
    int threadnum;
    taskQueue_t taskQueue;
    int exitFlag; // 不退出写0 退出写1
} threadPool_t;

 * */

#include "threadPool.h"
//参数线程池的结构体，和要生产的线程数量
int threadPoolInit(threadPool_t *threadPool, int workernum){
    //初始化线程池结构体
    bzero(threadPool, sizeof(threadPool_t));
    threadPool->threadnum = workernum;
    //放止野指针，实质上和bzero一样
    threadPool->tidArr = (pthread_t *)calloc(workernum,sizeof(pthread_t));
    //初始化锁，用来互斥的访问链队结构
    pthread_mutex_init(&threadPool->taskQueue.mutex,NULL);
    //初始化条件变量
    pthread_cond_init(&threadPool->taskQueue.cond,NULL);
    return 0;
}
